﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace ModernControls
{
	/// <summary>
	/// Interaction logic for NumberChanger.xaml
	/// </summary>
	public partial class NumberChanger : UserControl
	{
		#region DP prop


		public int Value
		{
			get { return (int)GetValue(ValueProperty); }
			set { SetValue(ValueProperty, value); }
		}

		// Using a DependencyProperty as the backing store for Value.  This enables animation, styling, binding, etc...
		public static readonly DependencyProperty ValueProperty =
			DependencyProperty.Register("Value", typeof(int), typeof(NumberChanger), new UIPropertyMetadata(0,new PropertyChangedCallback(
				(sender,args) =>
				{
					NumberChanger self = sender as NumberChanger;
					if (self != null)
					{
						if (self.ValueTextblock != null)
						{
							self.ValueTextblock.Text = self.Value.ToString();
						}
					}
				})));

		
		#endregion


		public NumberChanger()
		{
			InitializeComponent();
		}

		private void decButton_Click(object sender, RoutedEventArgs e)
		{
			Value--;
		}

		private void incButton_Click(object sender, RoutedEventArgs e)
		{
			Value++;
		}
	}
}
